/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.sql.Connection;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author Duc Quyen
 */
public class JobSeeker {

    private String email;
    private String password;
    private String name;
    private String gender;
    private Date birthday;
    private String address;
    private int provinceID;
    private String phone;
    private String branchID;
    private int JSID;

    public JobSeeker(String email, String password, String name, String gender, Date birthday, String address, int provinceID, String phone, String branchID) {
        this.email = email;
        this.password = password;
        this.name = name;
        this.gender = gender;
        this.birthday = birthday;
        this.address = address;
        this.provinceID = provinceID;
        this.phone = phone;
        this.branchID = branchID;
    }

    public JobSeeker(int JSID, String email, String name) {
        this.JSID = JSID;
        this.email = email;
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public Date getBirthday() {
        return birthday;
    }

    public String getName() {
        return name;
    }

    public String getBranchID() {
        return branchID;
    }

    public String getEmail() {
        return email;
    }

    public String getGender() {
        return gender;
    }

    public String getPassword() {
        return password;
    }

    public String getPhone() {
        return phone;
    }

    public int getProvinceID() {
        return provinceID;
    }

    public boolean save() {
        boolean result = false;
        Connection connection = ConnectDatabase.getConnection();
        try {
            Statement sta = connection.createStatement();
            String sql = "INSERT INTO jobseeker (Email,Password,Name,Gender,Birthday,Address,CityID,Phone,BranchID)"
                    + "VALUES('" + this.getEmail() + "','" + this.getEmail() + "','" + this.getName() + "','+" + this.getGender() + "','" + this.getBirthday() + "','"
                    + this.getAddress() + "'," + this.getProvinceID() + ",'" + this.getPhone() + "'," + this.branchID + ")";
            int number = sta.executeUpdate(sql);
            if (number == 1) {
                result = true;
            }
            connection.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return result;
    }
}
